package day1107_3;
//ObjectOutputStream
///ObjectIntputStream

import java.io.*;

//保存到文件中的类实现要实现Serializable接口(标记)
class Hero implements  Serializable{}

public class T1 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Hero liBai=new Hero();
        ObjectOutputStream oos=
                new ObjectOutputStream(new FileOutputStream("D:\\h.txt"));//1.创建ObjectOutputStream对象  oos
        oos.writeObject(liBai);//2. oos的writeObject()对象保存到文件中
        oos.close();//3.调用oos的close()释放文件


        ObjectInputStream ois=
                new ObjectInputStream(new FileInputStream("D:\\h.txt"));//1.创建ObjectOutputStream对象  oos
        Hero  lb=(Hero)ois.readObject();//2. oos的writeObject()对象保存到文件中
        System.out.println(lb);

        ois.close();//3.调用oos的close()释放文件
    }
}

